/**
 * 通知管理初始化
 */
var AutoCusEval = {
	processInterval:null
};



$(function () {
	$('#startDate').datebox(); 
	$('#endDate').datebox();
	$('#processbar').progressbar({  
	    value: 0  
	}); 
	//获取评估按钮的长度
	var btnWidth = $("#manual").width();
	$("#processbar").width(btnWidth);
	$(".progressbar-text").width(btnWidth);

	$("#entityId").combobox({
		url: Sys.backendPath + "/sds/common/entityCusList",
		mode:'remote',
		valueField:'value',
		textField:'text',
		multiple:true,
		rowStyle:'checkbox', //显示成勾选行形式
		selectOnNavigation:false,
		editable:false,
		defaultFilter: 6
	});
	
});

/**
 * 手动评估
 */
AutoCusEval.manualCus = function(){
	var startDate = $('#startDate').datebox('getValue');//开始日期
	var endDate = $('#endDate').datebox('getValue');//结束日期
	var patientId = $("#patientid").val();
	var entityId = $("#entityId").combobox("getValues").toString();
	if(startDate==""&&endDate==""&&patientId==""){
		Sys.info("请选择对应日期或就诊号")
		return ;
	}
	if (startDate != "") {
		startDate = startDate + " 00:00:00";
	}
	if (endDate != "") {
		endDate = endDate + " 23:59:59";
	}
	
	var ajax = new $ax(Sys.backendPath + "/sds/common/manualCusMrList", function (data) {
		
	}, function (data) {
        Sys.error("评估出错!");
    });
	ajax.setBeforSend(AutoCusEval.processInterval = setInterval(AutoCusEval.process, 1000));
	ajax.set({startDate: startDate, endDate: endDate, patientId: patientId, entityId: entityId});
	ajax.setAsync(true);
    ajax.start();
}
AutoCusEval.process = function(){
	//{"code":200,"message":"操作成功","v":100,"i":"done"}
	var ajaxProcess = new $ax(Sys.backendPath + "/sds/common/getProcess", function(data){
		$('#processbar').progressbar('setValue', data.v);  
		//刷新进度条
		if(data.v=="100"){
			clearInterval(AutoCusEval.processInterval);
		}
	},function(data){
        Sys.error("获取进度出错!" + data.responseJSON.message + "!");
    });
	ajaxProcess.setAsync(true);
	ajaxProcess.start();
}
